package com.smxy.mall.dao.impl;

import com.smxy.mall.dao.GoodsDaoExt;
import com.smxy.mall.model.response.GoodsResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GoodsDaoImpl implements GoodsDaoExt {
    @Autowired
    NamedParameterJdbcTemplate jdbcTemplate;
    @Override
    public List<GoodsResponse> recommendList() {
        Map<String,Object> sqlParamters = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(" select id,goodsName,cover,price,linePrice from fat_goods");

        return jdbcTemplate.query(stringBuilder.toString(),sqlParamters, BeanPropertyRowMapper.newInstance(GoodsResponse.class));

    }
}
